package com.lkd.controller;

import com.lkd.entity.Business;
import com.lkd.entity.Node;
import com.lkd.result.Result;
import com.lkd.service.BusinessService;
import com.lkd.service.NodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//点位管理
@Slf4j
@RestController
public class NodeController {

    @Autowired
    private NodeService nodeService;

    @Autowired
    private BusinessService businessService;


    //查询商圈列表
    @GetMapping("/api/vm-service/businessType")
    public Result findBusinessList() {
        List<Business> list = businessService.findList();
        return Result.success(list);
    }

    //新增点位
    @PostMapping("/api/vm-service/node")
    public Result save(@RequestBody Node node) {
        Boolean b = nodeService.save(node);
        return Result.success(b);
    }

    //修改点位
    @PutMapping("/api/vm-service/node")
    public Result update(@RequestBody Node node) {
        Boolean b = nodeService.update(node);
        return Result.success(b);
    }

    //修改点位
    @DeleteMapping("/api/vm-service/node/{id}")
    public Result update(@PathVariable("id") Long id) {
        Boolean b = nodeService.deleteById(id);
        return Result.success(b);
    }
}
